import numpy as np
import os
os.chdir(f'E:\hems7\mayavi_datavisualization')
# with open('test.axdt') as file:
with open('temperature.axdt') as file:
    fileStrings=file.readlines()
a=fileStrings.index('[Data]\n')
b=fileStrings.index('[Faces]\n')

c1=[]
for value in fileStrings[2:b]:
    if len(tmp:=(value.strip().split(',')))==4:
        c1.append(tmp)
vt=np.array(c1).astype(float)
v=vt[:,:3]
t=vt[:,3]
c1=[]
for value in fileStrings[b+1:]:
    if len(tmp:=(value.strip().split(',')))==3:
        c1.append(tmp)
f=np.array(c1).astype(int)

print(v,t,f)

from mayavi import mlab

surf = mlab.triangular_mesh(v[:, 0], v[:, 1], v[:, 2], f, scalars=t)

mlab.colorbar()

mlab.pipeline.surface(mlab.pipeline.extract_edges(surf), color=(0, 0, 0), )
mlab.show()
